home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Info-Mac 4
/
Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso
/
Sound
/
Utilities
/
ST201MusicDrivers Folder
/
Music Drivers
/
Simple Trecker.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-12-19
|
5KB
|
151 lines
/*** Simple Trecker.c ***/
/* Demonstration program to show how to use the Sound-Trecker Sound System V2.0.1. */
/* Frank Seide, 12/18/1993 */
/*
Copyright (c) 1991-93 by
Frank Seide
Wirichsbongardstr. 43
D-52062 Aachen
Germany
*/
/*
The 'PSTk' and 'ISTk' resources as well as this example source code may be used
freely in public domain programs under the conditions given in “The Sound-Trecker V2.0:
Licence Agreement”, e.g.:
• the resources themselves are copyrighted and not in the public domain!
The public domain program and the documentation must contain a copyright notice
like above, my address must be mentioned;
• you must send me one copy of the program;
• the code resources may not be modified (if you should find a bug, please tell me
to fix it. It´s important not to have too many different versions of the code);
• any kind of commercial use is forbidden and requires a special licence aggreement.
• for the exact details, see “The Sound-Trecker V2.0: Licence Agreement”
*/
#include <stdio.h>
#include <sound.h>
#include "PSyn.h"
#include "STrI.h"
main()
{
/* The program requires the Sound Manager of System 7 (contained in System 6.0.7 */
/* and above). The 'PSyn' code verifies this before opening the sound channel. */
/* You may want to do this verification in the main program to provide user feedback */
/* (not shown in this example). */
/* A 68020 is no longer required (as in V1.0). However, for 68000 Macs, an ASC */
/* is required, as in the Portable and the Powerbook 100. This is a problem of the */
/* Sound Manager. */
/* Variables: */
int i;
PChannelPtr pc = NULL; /* Sound-Trecker Sound System Descriptor */
SoundTrackHandle strk = NULL; /* Handle to current MOD */
/* Constants: */
const Boolean stereo = FALSE; /* Stereo ? */
const Boolean fadeOut = TRUE; /* fade out on stop ? */
const Boolean realTimeFilter = FALSE; /* use real time filter ? */
const Boolean preFilter = TRUE; /* prefilter at load time ? */
const Fixed sampleRate = rate22khz; /* output sample rate */
/* Initialize the Mac OS: */
InitGraf (&thePort);
InitFonts();
FlushEvents (everyEvent, 0);
InitWindows();
InitMenus();
TEInit();
InitDialogs (NULL);
InitCursor();
/* Open the Sound-Trecker Sound System (limit to 32 voices; 16 bit if available): */
if (OpenPChannel (32, (stereo ? opc_stereo : 0) + opc_16Bit, 820*8, &pc)) {
SysBeep (30); exit();
}
/* Set the output sample rate (OpenPChannel() defaults to 22 kHz). */
/* Note always to stop playing before changing the sample rate. */
/* Warning: the old variable pc->softFreq of V1.0 no longer exists in V2.0 */
pc->hardFreq = sampleRate;
/* Change Sound System options: */
pc->antiAlias = realTimeFilter; /* Apply real time filter ? */
pc->userMixing = FALSE; /* Default channel mixing */
pc->noSurround = stereo; /* Allow for stereo surround effects */
/* Set channel volumes and the total volume. This could be left out in this example, */
/* because the volumes are initialized by OpenPChannel() exactly as we do here. */
/* The channel volumes are ignored, if pc->userMixing = FALSE (as in this example). */
/* The volumes may also be changed with this call, when the Sound System is playing. */
for (i = 0; i < 32; i++) PChannelVolume (pc, i, 0x10000); /* Fixed 0x10000 = 100% */
PChannelVolume (pc, -1, 0x08000); /* -1 = Gesamtlautst. / -1 denotes total volume */
/* Main event loop: */
while (TRUE) {
/* Let the user select a MOD file with a standard file dialog: */
SFTypeList theTypeList = { 'STrk' };
StandardFileReply theReply;
StandardGetFile (NULL, 1, theTypeList, &theReply);
/* Quit main loop if user selects “Cancel”: */
if (!theReply.sfGood) { StopPChannel (pc, fadeOut); break; }
/* Stop the current MOD if there is one: */
if (strk) { /* Is there a MOD to be stopped ? */
StopPChannel (pc, fadeOut); /* fade out & stop */
UnlinkSoundTrack (strk); /* unlink MOD from Sound System */
DisposeSoundTrack (strk); /* now free memory occupied by MOD */
strk = NULL; /* no MOD any more */
}
/* Now load the MOD the user selected: */
if (FSpGetSoundTrack (&theReply.sfFile, preFilter ? 1 : 0, &strk, FALSE))
SysBeep (30); /* (Load error) */
else {
/* Change MOD options: */
/* Warning: access workspace variables only using GetSoundTrackWorkspace() */
GetSoundTrackWorkspace (strk)->loopDetect = TRUE;
/* Link MOD to Sound System: */
LinkSoundTrack (strk, pc);
/* At this point, in Simple Trecker V1.0 the total volume was reset to 50%, */
/* because it became zero due to fading out. Resetting the volume is */
/* no longer necessary in V2.0. */
/* PChannelVolume (pc, -1, 0x08000); (Not required any more) */
/* Reset song pointers to start: */
ResetPChannel (pc);
/* Start Sound System: */
if (StartPChannel (pc)) { SysBeep (30); break; }
}
}
/* Close the Sound System (required on System 6.0.7!): */
ClosePChannel (pc);
}